Is there a method to delete characters?

A good answer might be:

No — there are only methods that append characters or insert characters.


Revised Example

There is a reverse() method in class StringBuffer that reverses the order of the characters. Let us conveniently forget about that method and re-write our previous example program:

public class ReverseTester
{

  public static String reverse( String data )
  {
    StringBuffer temp = new StringBuffer();

    for ( int j=data.length()-1; j >= 0; j-- )
      temp.append( data.charAt(j) );

    return temp.toString();
  }

  public static void main ( String[] args )
  {
    System.out.println( reverse( "Hello" ) );
  }
}

In this version of reverse(), only two new objects are created: the StringBuffer and the String object that is returned to the caller.

QUESTION 7:

Does this program make any assumptions about the size of the String?